package com.simplehire.repository;

import com.simplehire.model.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.Optional;

@Repository
public interface UserRepository extends JpaRepository<User, Long> {
    // 按用户名查询用户，用于检测重复
    Optional<User> findByUsername(String username);

    // 检查用户名是否已存在
    default boolean existsByUsername(String username) {
        return findByUsername(username).isPresent();
    }
}
